﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//
using PerceptiveMCAPI;
using PerceptiveMCAPI.Types;
//

namespace PerceptiveMCAPI_Test
{
   public partial class show_API_Response : System.Web.UI.UserControl
   {
      public bool Show_Formatted { get; set; }
      public bool Show_Unformatted { get; set; }
      public bool Show_ToString { get; set; }
      //
      public string api_UnformattedResponse
      {
         get { return litUnformattedResponse.Text.Trim(); }
         set { litUnformattedResponse.Text = value; }
      }
      public string api_ResponseLength
      {
         get { return lblResponseLen.Text.Trim(); }
         set { lblResponseLen.Text = value; }
      }
      public string api_ResponseToString
      {
         get { return litResponseToString.Text.Trim(); }
         set { litResponseToString.Text = value; }
      }

      // --------------------------------------------------------------
      public void Display()
      {
         this.Visible = true;
         if ( this.Show_Formatted ) this.ShowFormatted(); else this.HideFormatted();
         if ( this.Show_Unformatted ) this.ShowUnformatted(); else this.HideUnformatted();
         if ( this.Show_ToString ) this.ShowToString(); else this.HideToString();
      }
      public void Hide()
      {
         this.Visible = false;
      }
      // ---------------------------------------------------- show
      public void ShowUnformatted()
      {
         divUnformatedResponse.Visible = true;
      }
      public void ShowFormatted()
      {
         Parent.FindControl( "pnlResponse" ).Visible = true;
         divFormatedResponse.Visible = true;
      }
      public void ShowToString()
      {
         if ( string.IsNullOrEmpty( api_ResponseToString ) )
            api_ResponseToString = "** No ToString() value was found **";
         divResponseToString.Visible = true;
      }
      // -------------------------------------------------------------------------------- hide
      public void HideUnformatted()
      {
         divUnformatedResponse.Visible = false;
      }
      public void HideFormatted()
      {
         Parent.FindControl( "pnlResponse" ).Visible = false;
         divFormatedResponse.Visible = false;
      }
      private void HideToString()
      {
         divResponseToString.Visible = false;
      }
      // ---------------------------------------------------------------------------------- close
      protected void lbtnCloseUnformatted_Click( object sender, EventArgs e )
      {
         HideUnformatted();
      }
      protected void lbtnCloseFormatted_Click( object sender, EventArgs e )
      {
         HideFormatted();
      }
      protected void lbtnCloseToString_Click( object sender, EventArgs e )
      {
         HideToString();
      }
   }
}